--[[
关卡详细信息显示
]]
local LevelInfoSprite = class("LevelInfoSprite", BaseSprite)




function LevelInfoSprite:initView()
  	--卡片信息
 	self.txt_title_ = cc.ui.UILabel.new({
        text = "==================关片信息============================",
        size = 16,
        color = display.COLOR_WHITE,
    }):align(display.BOTTOM_LEFT, 0, 140):addTo(self)
  
  	self.txt_levelId_ = cc.ui.UILabel.new({
        text = "关卡levelId:",
        size = 16,
        color = display.COLOR_WHITE,
    }):align(display.BOTTOM_LEFT, 0, 120):addTo(self)
    
 
 
 
    cc.ui.UILabel.new({
        text = "关卡总能量值energyFullNums:",
        size = 16,
        color = display.COLOR_WHITE,
    }):align(display.BOTTOM_LEFT, 0, 100):addTo(self)
    
 	self.txt_energyFullNums_ = cc.ui.UIInput.new({
		UIInputType = 2,
        --placeHolder = options.PlaceHolderText,
        x = 240,
        y = 110,
        text = "",
         listener =  function(textfield, eventType)
					    if eventType == 0 then
					        -- ATTACH_WITH_IME
					    elseif eventType == 1 then
					        -- DETACH_WITH_IME
					    elseif eventType == 2 then
					        -- INSERT_TEXT
					    elseif eventType == 3 then
					        -- DELETE_BACKWARD
					    end
					    self.model_.levelData_.energyFullNums = self.txt_energyNums_:getString();
					end,
        size = cc.size(30, 40),
        --passwordEnable = options.PasswordEnable,
        --font = options.FontResource and options.FontResource.Path,
        fontSize = 16,
        --maxLength = options.MaxLengthEnable and options.MaxLengthText
    }):addTo(self)
 	
 	   
    
     cc.ui.UILabel.new({
        text = "关卡当前能量值energyNums:",
        size = 16,
        color = display.COLOR_WHITE,
    }):align(display.BOTTOM_LEFT, 0, 80):addTo(self)
    
    self.txt_energyNums_ = cc.ui.UIInput.new({
		UIInputType = 2,
        --placeHolder = options.PlaceHolderText,
        x = 240,
        y = 90,
        text = "",
        size = cc.size(30, 40),
        listener =  function(textfield, eventType)
					    if eventType == 0 then
					        -- ATTACH_WITH_IME
					    elseif eventType == 1 then
					        -- DETACH_WITH_IME
					    elseif eventType == 2 then
					        -- INSERT_TEXT
					    elseif eventType == 3 then
					        -- DELETE_BACKWARD
					    end
					    self.model_.levelData_.energyNums = self.txt_energyNums_:getString();
					end,
        --passwordEnable = options.PasswordEnable,
        --font = options.FontResource and options.FontResource.Path,
        fontSize = 16,
        --maxLength = options.MaxLengthEnable and options.MaxLengthText
    }):addTo(self)
    
    
  
   cc.ui.UILabel.new({
        text = "关卡类型levelType： ",
        size = 16,
        color = display.COLOR_WHITE,
    }):align(display.BOTTOM_LEFT, 0, 50):addTo(self)
    local RADIO_BUTTON_IMAGES = {
	    off = "#StopMapButton.png",
	    off_pressed = "#StopMapButton.png",
	    off_disabled = "#StopMapButton.png",
	    on = "#StopMapButtonSelected.png",
	    on_pressed = "#StopMapButtonSelected.png",
	    on_disabled = "#StopMapButtonSelected.png",
	}
    local group = cc.ui.UICheckBoxButtonGroup.new(display.LEFT_TO_RIGHT)
        :addButton(cc.ui.UICheckBoxButton.new(RADIO_BUTTON_IMAGES)
            :setButtonLabel(cc.ui.UILabel.new({text = "步数模式",size = 16, color = display.COLOR_WHITE}))
            :setButtonLabelOffset(20, 0)
            :align(display.BOTTOM_LEFT))
        :addButton(cc.ui.UICheckBoxButton.new(RADIO_BUTTON_IMAGES)
            :setButtonLabel(cc.ui.UILabel.new({text = "能量模式",size = 16, color = display.COLOR_WHITE}))
            :setButtonLabelOffset(20, 0)
            :align(display.BOTTOM_LEFT))
        :setButtonsLayoutMargin(0, 10, 0,10)
        :onButtonSelectChanged(function(event)
            printf("Option %d selected, Option %d unselected", event.selected, event.last)
            if self.model_ then
            	self.model_.levelData_.levelType = event.selected - 1;
            end
        end)
        :align(display.BOTTOM_LEFT, 130, 50)
        :addTo(self)
    group:getButtonAtIndex(1):setButtonSelected(true)
    self.group_levelType_ = group;
    
    
    self.txt_isW_ =cc.ui.UILabel.new({
        text = "关卡背景音乐:",
        size = 16,
        color = display.COLOR_WHITE,
    }):align(display.BOTTOM_LEFT, 0, 20):addTo(self)
    
end




function LevelInfoSprite:updateView(targetCard)
	local model = targetCard.model_;
	self.model_ = model;
	
	self.txt_levelId_:setString("关卡levelId：	"..model.levelData_.levelId);
	self.txt_isW_:setString("关卡背景音乐：	"..model.levelData_.sceneSound);
	
	
	self.txt_energyFullNums_:setString(model.levelData_.energyFullNums);
	self.txt_energyNums_:setString(model.levelData_.energyNums);
	
	self.group_levelType_:getButtonAtIndex(model.levelData_.levelType+1):setButtonSelected(true)
end




return LevelInfoSprite
